﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HidesaburoDotNET.Core2
{
    public class Player : IEnemy ,IMyAvator
    {
        #region IEnemy メンバ


        public IEnemyCards Cards
        {
            get { throw new NotImplementedException(); }
        }

        public bool Reached
        {
            get { throw new NotImplementedException(); }
        }

        public int Score
        {
            get { throw new NotImplementedException(); }
        }

        public bool Parent
        {
            get { throw new NotImplementedException(); }
        }

        public Kaze Kaze
        {
            get { throw new NotImplementedException(); }
        }

        #endregion

        #region IMyAvator メンバ


        IMyCards IMyAvator.Cards
        {
            get { throw new NotImplementedException(); }
        }

        #endregion

        Cards cards;
        Field field;
        Hou myHou;

        public void Tsumo(Hai hai)
        {
            cards.Add(hai);
        }

        public void EnemyDiscarded(Player enemy, Hai discard)
        {
            currentPhase = PlayerPhase.EnemyDiscarded;
        }

        PlayerPhase currentPhase = PlayerPhase.NotInGame;

        #region IMyAvator メンバ


        public void Discard(Hai hai)
        {
            if (currentPhase != PlayerPhase.MyTurn)
            {
                throw new ForbiddenActionException("自分の番ではないので牌を捨てることは出来ません");
            }
            cards.Remove(hai);
            myHou.Add(hai);
            currentPhase = PlayerPhase.WaitingAction;

            field.OnDiscarded(this, hai);
        }

        public void Ankan(Hai hai)
        {
            throw new NotImplementedException();
        }

        public void Pon()
        {
            throw new NotImplementedException();
        }

        public void Chi(ChiType type)
        {
            throw new NotImplementedException();
        }

        public void Chi()
        {
            throw new NotImplementedException();
        }

        public void Kan()
        {
            throw new NotImplementedException();
        }

        public void Ron()
        {
            throw new NotImplementedException();
        }
        public void Pass()
        {
        }

        public void Agari()
        {
            throw new NotImplementedException();
        }

        #endregion

        #region IMyAvator メンバ

        public IHou Hou
        {
            get { throw new NotImplementedException(); }
        }

        #endregion
    }

    enum PlayerPhase
    {
        NotInGame,
        MyTurn,
        EnemyDiscarded,
        WaitingAction
    }

    public class ForbiddenActionException : Exception
    {
        public ForbiddenActionException(string message)
            : base(message)
        {
        }
    }

}
